# templates/schema.py.j2
from datetime import datetime
from fastapi_utils.api_model import APIModel
from pydantic import Field
from typing import Optional
from fastapi import Depends, Query
from src.core.dependencies import QueryParams, Paging
from src.core.query_builder import FilterCriteria, QueryType
from src.schemas.base_schema import MixinSchema


class CodegeneratorParams(QueryParams):
    def __init__(
        self,
        params: Paging = Depends(Paging),
    ):
        super().__init__(params)


class CodegeneratorCreate(APIModel):
    field_name: str = Field(
        ...,
        description="字段名称",
    )
    field_type: Optional[str] = Field(
        ...,
        description="类型",
    )
    field_description: Optional[str] = Field(
        ...,
        description="字段描述",
    )
    field_default_value: Optional[str] = Field(
        ...,
        description="默认值",
    )
    field_is_key: Optional[bool] = Field(
        ...,
        description="是否主键",
    )
    field_is_nullable: Optional[bool] = Field(
        ...,
        description="是否允许为空",
    )
    field_is_unique: Optional[bool] = Field(
        ...,
        description="是否唯一",
    )
    field_is_auto_increment: Optional[bool] = Field(
        ...,
        description="是否自增",
    )


class CodegeneratorUpdate(CodegeneratorCreate):
    id: int = Field(..., title="id")


class CodegeneratorOut(MixinSchema, CodegeneratorCreate):
    pass
